<?php

namespace Modules\Payment\Http\Controllers\Client\V1;

use Illuminate\Http\Request;
use Illuminate\Routing\Controller;

use \Modules\Order\Entities\UnionOrder;
use \Modules\Order\Entities\BaseOrder as Order;

use Validator;
use ThrowException;
use Payment;
use Auth;

class PaymentController extends Controller
{
    // 微信支付回调
    public function detail(Request $req, $uuid)
    {
        $order = Order::getDerivedOrder([
            'uuid' => $uuid
        ]);

        $res = [
            'money' => $order->pay_money_price,
            'method' => [
                'wechat_pay' => [
                    'is_enable' => 1
                ],
                'alipay' => [
                    'is_enable' => 0
                ]
            ]
        ];

        return $res;
    }

    public function config(Request $req, $uuid)
    {
        $order = Order::getDerivedOrder([
            'uuid' => $uuid
        ]);

        // $payType = $req->input('pay_type');
        // $paySubType = $req->input('sub_type');

        $options = [
            'pay_type' => $req->input('pay_type')
        ];

        $res = $order->generateResponse($options);

        return $res;

        // $paySubType = $paySubType;

        // $user = Auth::requireLoginUser();
        // $clientName = Auth::clientName();

        // $config = Payment::wechatPay($clientName, $paySubType)->config($user, $order);

        // return [
        //     'pay_config' => $config
        // ];
    }

}
